export function formatTimeStamp(timestamp) {
    const now = Date.now();
    const diff = now - timestamp;

    const oneMinute = 60 * 1000;
    const oneHour = 60 * oneMinute;
    const oneDay = 24 * oneHour;
    const oneMonth = 30 * oneDay; // 近似一个月
    const threeMonths = 3 * oneMonth;

    if (diff < oneMinute) {
        return "1分钟内";
    } else if (diff < oneHour) {
        const minutes = Math.floor(diff / oneMinute);
        return `${minutes}分钟`;
    } else if (diff < oneDay) {
        const hours = Math.floor(diff / oneHour);
        return `${hours}小时`;
    } else if (diff < oneMonth) {
        const days = Math.floor(diff / oneDay);
        return `${days}天`;
    } else if (diff < threeMonths) {
        const months = Math.floor(diff / oneMonth);
        return `${months}个月`;
    } else {
        return null;
    }
}

//封装弹窗
export function showToast(title="",icon="none",mask=true){
	let posttion = icon=='none' ? 'bottom' :"center";
	uni.showToast({
		title,
		icon,
		mask,
		posttion
	})
}


//审核状态组
export const stateLists = [{
	"value": 0,
	"text": "审核中",
	"color":"#F3A73F",
	"bgColor":"#FDEDD9"
},
{
	"value": 1,
	"text": "审核通过",
	"color":"#18BC37",
	"bgColor":"#D1F2D7"
},
{
	"value": 2,
	"text": "审核不通过",
	"color":"#E43D33",
	"bgColor":"#FAD8D6"
}]

//传入value值返回，状态对象
export function stateFormat(value){
	return stateLists.find(item=>item.value == value)
}
